'''
# 数据处理层Model：实现json数据读取load、写入dump
'''
import json
def read_data(path):
    with open(path,mode='r',encoding='utf-8') as f:
        data=json.load(f)
    return data

def write_data(data_list,path):
    with open(path,mode='w',encoding='utf-8')as f:
        json.dump(data_list,f,ensure_ascii=False)



if __name__ == '__main__':
    #测试一下
    # path=r'username.json'
    # print(read_data(path))
    path= r'username.json'
    data_list=[{"username": "zhangsan", "password": "123"},
               {"username": "lisi", "password": "123"},
               {"username": "wangwu", "password": "123"},
               {"username": "zhaoliu", "password": "123"},
               {"username": "wangermazi", "password": "123"}]
    write_data(data_list, path)